
// 编辑数据
function  bianji(obj){
let objval = $(obj).parent().siblings('td')
$('.modal-content').html(`
<div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                    aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="exampleModalLabel">编辑数据</h4>
                </div>
                <div class="modal-body clear">
            
                <div class="modal-body clear">
                    <p class="xsmt">
                    <span>编号：</span><input type="text" value=${objval.eq(0).text()} />
                    </p>
                    <p class="xsmt">
                    <span>商品名称：</span><input type="text" value=${objval.eq(1).text()} "/>
                    </p>
                    <p class="xsmt">
                    <span>商品分类：</span><input type="text" value=${objval.eq(2).text()} />
                    </p>
                    <p class="xsmt">
                    <span>出库数量：</span><input type="text" value=${objval.eq(3).text()} />
                    </p>
                    <p class="xsmt">
                        <span>入库日期：</span>  <input type="date" class="form-control kuangkuang" value="${objval.eq(4).text()}" name="ruku" id="ruku" >
                    </p>
                </div>
                <div class="modal-footer fenge">
                    <button type="button" class="btn btn-default addbtn_ok" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary addbtn_no" onclick="Change()"  data-dismiss="modal">确认</button>
                </div>
            
            </div>`)
            console.log(123);
}
//添加数据
function Change(){
for(let i=0; i<allData.length; i++){
    if(allData[i].bh==$('.xsmt').eq(0).children().last().val()){
    allData[i].bh = $('.xsmt').eq(0).children().last().val()
    allData[i].spmc = $('.xsmt').eq(1).children().last().val()
    allData[i].spfl = $('.xsmt').eq(2).children().last().val()
    allData[i].cksl = $('.xsmt').eq(3).children().last().val()
    allData[i].ckrq =  $('.xsmt').eq(4).children().last().val()
    }
}
goPage(dangqianye)
// console.log(goPage(nowPageNum));
}
//删除商品
function delsan(obj) {
let objval = $(obj).parent().siblings('td')
let delxs = objval.first().text()
$('.modal-content').html(`
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
        aria-hidden="true">&times;</span></button>
    <h4 class="modal-title" id="myModalLabel">删除商品</h4>
    </div>
    <div class="modal-body">
    <p>确认删除商品编号为：${delxs}&nbsp的商品数据吗？</p>
    </div>
    <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
    <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="shanchu(${delxs})">确定</button>
    </div>`)
}
//删除数据
function shanchu(spBh) {
        for (let i = 0; i < allData.length; i++) {
            if (spBh == allData[i].bh) {
            allData.splice(i, 1)
            break;
            }
        }
        showDiv(allData)
        goPage(dangqianye)
}
// 选项卡
function tabClick(domNode,num){
let content1=document.getElementsByClassName('content1')
domNode.style.backgroundColor = 'white'
domNode.style.color ='blue'
domNode.style.borderTop='3px solid blue'
domNode.style.borderLeft='1px solid blue'
domNode.style.borderRight='1px solid blue'


//颜色改变
for (let i = 0; i < li1.length; i++) {                     
    if (domNode != li1[i]) {
    li1[i].style.backgroundColor = 'blue'
    li1[i].style.color ='white'
    }
}
content1[num].style.display = 'block'                             
 //显示被点击的内容
for (let i = 0; i <content1.length; i++) {
    if (num != i) {
    content1[i].style.display = 'none '                     //不是被点击的内容隐藏
    }
}
}
//添加类别
function addck() {
    $('.modal-content').html(`
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
        aria-hidden="true">&times;</span></button>
    <h4 class="modal-title" id="myModalLabel">添加分类</h4>
    </div>
    <div class="modal-body">
    <p>确认添加此商品类别吗？</p>
    </div>
    <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
    <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="tianjia()">确定</button>
    </div>`)

}
// 添加分类
function tianjia(){
    let add = new AddckData()
    allData.unshift(add)
    goPage(dangqianye)
}
function AddckData() {
        this.bh=$('#bianhao').val()
        this.spfl =$('#ckfl option:selected').text()
        this.spmc = $('#ckmc option:selected').text()
        this.cksl = $('#shuliang').val()
        this.ckrq = $('#cukuriqi').val()
}
function pullDown(obj) {
    let num = obj.siblings().length + 1
    if (!h_judge) {
        obj.parent().css({
            'height': num * 40 + 'px'
        })
        obj.children().last().css({
            'transform': 'rotate(180deg)'
        })
    } else {
        obj.parent().css({
            'height': 40 + 'px'
        })
        obj.children().last().css({
            'transform': 'rotate(0deg)'
        })
    }
    h_judge = !h_judge

}
function jumpPage(obj) {
    switch (obj.attr('page-data')) {
        case 'page1': location.href = './flgl.html';
        break
        case 'page2': location.href = './kcgl.html';
        break
        case 'page3': location.href = './rkgl.html';
        break
        case 'page4': location.href = './yjxxsz.html';
        break
        case 'page5': location.href = './ckgl.html';
        break
        case 'page6': location.href = './yhgl.html';
        break
        case 'page7': location.href = './xgmm.html';
        break
        }
    let page
    sessionStorage.setItem('page', obj.attr('page-data'))
}

  